#include "Precompiled.hpp"
#include "GlobalContainer.hpp"

class TestComponent : public ComponentInterface
{
public:
  int x,y,z;

  void Register(void)
  {
    Serializer::RegisterInt(parent, "Test", "x", &x);
    Serializer::RegisterInt(parent, "Test", "y", &y);
    Serializer::RegisterInt(parent, "Test", "z", &z);
  }

};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
  //GlobalContainer globalContainer;

  //globalContainer.Run();
  
  int a = 0;
  Factory<int> myfactory;
  Handle<int> handle1 = myfactory.CreateNewObject();
  Handle<int> handle2 = myfactory.CreateNewObject();
  Handle<int> handle3 = myfactory.CreateNewObject();
  Handle<int> handle4 = myfactory.CreateNewObject();
  Handle<int> handle5 = myfactory.CreateNewObject();
  *handle1 = 1;
  *handle2 = 2;
  *handle3 = 3;
  *handle4 = 4;
  *handle5 = 5;
  handle1.Delete();
  handle3.Delete();
  handle5.Delete();
  int a2 = *handle2;
  int a4 = *handle4;
  //int a3 = *handle3;

  
  Factory<Entity> blargFactory;
  Handle<Entity> entity = blargFactory.CreateNewObject();

  Factory<TestComponent> testFactory;
  Handle<TestComponent> test1 = testFactory.CreateNewObject();
  test1->SetParent(entity);
  entity->AddComponent(test1);
  test1->Register();
  test1->x = 300;
  test1->y = 9001;
  test1->z = -1;
  Serializer::SaveAll();
  return 0;
}